<?php 

    session_start ();
    include 'function.php';
    display_header();
    if (isset($_SESSION['login']) && isset($_SESSION['mdp'])) {
    include 'include/Data.php';
    
    $req = mysql_query('SELECT Id_machine, Nom_machine, Os_Type, Taille_Ram, Started FROM machine_virtuel ORDER BY Nom_machine ASC');
    $ligne = mysql_fetch_assoc($req);
    echo '<i><u>Machines Virtuels:</u></i><br><br>';
    
    while ($ligne) {
        if ($ligne['Os_Type'] == 'Debian')
        {
        ?><div style="background: url(img/Debian.png) no-repeat; width: 750px;height: 200px; font-size: 1.55em;">
            <br><br><p align="center"><?php echo $ligne['Nom_machine']; ?></p>
            <p align="center"><?php echo $ligne['Taille_Ram'];?>Mo</p>
            <p align="right">
            <a href="statistique.php?VM=<?php echo $ligne['Nom_machine'];?>">Statistique</a>
            <?php 
            VM_state ($ligne['Id_machine'], $ligne['Started']);
            ?>
            <a href="delete.php?VM=<?php echo $ligne['Id_machine'];?>"><img src="img/delete.png"  width=40 height=40 alt="Supprimer"/></a></p>
            </div>
            <?php
        }
        
        if ($ligne['Os_Type'] == 'Ubuntu')
        {
        ?><div style="background: url(img/Ubuntu.png) no-repeat; width: 750px;height: 200px; font-size: 1.55em;">
            <br><br><p align="center"><?php echo $ligne['Nom_machine']; ?></p>
            <p align="center"><?php echo $ligne['Taille_Ram'];?>Mo</p>
            <p align="right">
	    <a href="statistique.php?VM=<?php echo $ligne['Nom_machine'];?>">Statistique</a>
            <?php
            VM_state ($ligne['Id_machine'], $ligne['Started']);
            ?>
            <a href="delete.php?VM=<?php echo $ligne['Id_machine'];?>"><img src="img/delete.png"  width=40 height=40 alt="Supprimer"/></a></p>
            </div>
            <?php
        }

        $ligne = mysql_fetch_assoc($req);
        }

    display_footer();
    } else { header("Refresh: 0; URL=index.php"); }
    is_log();

?>
